const { createProxyMiddleware } = require('http-proxy-middleware')

// 是一个代理中间件，用于转发请求，将客户端发送的请求数据转发到目标服务器，再将响应输送到客户端。

module.exports = function (app) {
  /*app.use(function (req, res, next) {
    next()
  })
  */
  app.use(
    createProxyMiddleware('/api', {
      target: 'http://localhost',
      changeOrigin: true,
      pathRewrite: {
        "^/api": ""
      }
    })
  )
  /*app.use(
    createProxyMiddleware('/api2', {
      target: 'http://192.168.100.121:3000',
      changeOrigin: true,
      pathRewrite: {
        "^/api2": ""
      }
    })
  )*/
}

